package com.itany.corejava.code07_面向对象.bms;

/**
 * @author: 石小俊
 * @date: 2023年03月09日 17:06
 * @version: 1.0
 */
public class CreditAccount extends Account {
    private double limit;

    public double getLimit() {
        return limit;
    }

    public void setLimit(double limit) {
        this.limit = limit;
    }

    @Override
    public boolean withdrawMoney(double money) {
        // 当账户余额+透支额度 >= 取款的金额,取款才能成功
        if (getBalance() + limit >= money) {
            // 取款后金额减少
            setBalance(getBalance() - money);
            return true;
        }
        return false;
    }
}
